//
//  BaseTableViewController.swift
//  CXCWeibo
//
//  Created by cxc on 15/6/24.
//  Copyright © 2015年 china. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorViewDelegate{

    var userLogin = sharedUserAccount != nil
    var visitorView:VisitorView?
    
    override func loadView() {
        
        userLogin ? super.loadView() : setupVisitorView()
    }
    
    /**
    创建访客视图
    */
    private func setupVisitorView(){
        visitorView = VisitorView()
        visitorView?.delegate = self
        view = visitorView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorRegisterButtonClicked")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginButtonClicked")
    }
    // MARK:  -代理方法实现 =>
    func visitorLoginButtonClicked() {
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        
        presentViewController(nav, animated: true, completion: nil)
    }
    func visitorRegisterButtonClicked() {
        print("注册")
    }

}
